package com.example.demo.util;

import com.example.demo.DTO.UserDTO;

public class UserHolder {

    private static final ThreadLocal<UserDTO> threadLocal = new ThreadLocal<>();

    /**
     * 保存登录用户
     *
     * @param userDTO
     */
    public static void saveUser(UserDTO userDTO) {
        threadLocal.set(userDTO);
    }

    public static UserDTO getUser() {
        return threadLocal.get();
    }

    public static void removeUser() {
        threadLocal.remove();
    }
}
